package com.two.zelin.controller;
//查询订单
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;
import com.two.zelin.model.order;
import com.two.zelin.service.orderService;
import com.two.zelin.service.impl.orderServiceImpl;

//设置网络访问地址
@WebServlet("/selecetorder.do")
public class SelectorderAllServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		orderService  service = new orderServiceImpl();
		List<order> list = service.selectAll();
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");
		PrintWriter pw = resp.getWriter();
		Gson gson = new Gson();
		String result = gson.toJson(list);
		pw.append(result);
		pw.flush();
		pw.close();
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doGet(req, resp);
	}
}
